#!/bin/bash -ex

REPOS=(\
    "/home/aleks/repos/idlize" \
    "/home/aleks/repos/idlize/external" \
)

#    "/home/aleks/repos/idlize/core/webidl2.js" \

DEF_BRANCH="master"
REMOTE_ORIG_REPO="origin"
REMOTE_BRANCH="${REMOTE_ORIG_REPO}/master"

for REPO in ${REPOS[@]}
do
    echo "Updating repo: ${REPO} ..."
    cd ${REPO}
    git stash
    git checkout "${DEF_BRANCH}"
    git fetch ${REMOTE_ORIG_REPO}
    git reset --hard "${REMOTE_BRANCH}"
    echo "Done repo: ${REPO}"
done

REPO_WEBJS="/home/aleks/repos/idlize/core/webidl2.js"
cd ${REPO_WEBJS}
git checkout main
git fetch origin
git stash
git reset --hard origin/main

echo "WIN_WIN"
